import java.awt.Color;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.geom.GeneralPath;
import java.util.ArrayList;


public class Graph {
	private ArrayList<Double> data;
	private ViewPanel panel;
public Graph(ArrayList<Double>data,ViewPanel v){
	this.data=data;
	this.panel=v;
}
private GeneralPath path = new GeneralPath();

public void draw(Graphics g2){
	Graphics2D g = (Graphics2D) g2;
	double amt = data.get(panel.minX);
	path.moveTo(
			20,
			panel.getHeight()
					- (int) (((double) amt - panel.minY) / (panel.maxY - panel.minY) * (panel
							.getHeight() - 20)) - 20);
	g.setColor(Color.blue);
	for (int i = 0; i < panel.getWidth(); i++) {
		amt = data.get((int) (((double) i / panel.getWidth())
				* (panel.maxX - panel.minX) + panel.minX));
		// g.drawLine(i, panel.getHeight(),
		// i,panel.getHeight()-(int)(((double)amt-minY)/(maxY-minY)*panel.getHeight())
		// );
		path.lineTo(
				i + 20,
				panel.getHeight()
						- (int) (((double) amt - panel.minY) / (panel.maxY - panel.minY) * (panel
								.getHeight() - 20)) - 20);

	}
	g.draw(path);
	path.reset();
}
}
